<?php
namespace Home\Biz;

class MailBiz{
	
	
	public static function callMailApi($toMail,$subject,$content)
	{
		$url = C('Api.MailApi');
		$post_data = array(
  			'to' => $toMail,
 			 'subject' => $subject,
				'content' =>$content
  			);
		self::http_post_json($url,json_encode($post_data));
    }
    
    function http_post_json($url, $jsonStr)
    {
    	$ch = curl_init();
    	curl_setopt($ch, CURLOPT_POST, 1);
    	curl_setopt($ch, CURLOPT_URL, $url);
    	curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    			'Content-Type: application/json; charset=utf-8',
    			'Content-Length: ' . strlen($jsonStr)
    	)
    			);
    	$response = curl_exec($ch);
    	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    	return array($httpCode, $response);
    }
}